//
// Created by Castle-Moriarty on 2025/10/31.
//

#include <iostream>
using namespace std;

int main() {
    // 求数组中第二大的值
    int n,a[100],max1,max2;
    cin >> n;
    for (int i = 1;i <= n;i++) {
        cin >> a[i];
    }

    max1 = max2 = a[1];

    for (int i = 2;i <= n; i++) {
        if (a[i] > max1) {
            max2 = max1;
            max1 = a[i];
        }else if (a[i] > max2) {
            max2 = a[i];
        }
    }
    cout << max2 << endl;
    return 0;
}